<template>
<div>
   <div class="left">
    <h2>Top组件</h2>
    {{ msg }} 
    <br/>
    <button @click="sendMsg">传递数据到Bottom组件</button>
  </div>
</div>
</template>

<script>
//1.引入eventBus
import bus from '../utils/eventBus'
export default {
  name: 'TopDemo',
  data() {
    return {
      msg: '雕栏玉砌应犹在',
    };
  },
  methods: {
    sendMsg() {
      //2.引用bus的$emit方法传递数据
      bus.$emit("shareData",this.msg);
    },
  }
}
</script>

<style scoped>
.left {
  width: 600px;
  height: 300px;
  background: pink;
}
</style>